package com.ruoyi.cbs.project.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.cbs.project.domain.vo.ProjectInfoRespVO;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cbs.project.mapper.ProjectMapper;
import com.ruoyi.cbs.project.domain.Project;
import com.ruoyi.cbs.project.service.IProjectService;

/**
 * 承包商项目Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-11-12
 */
@Service
public class ProjectServiceImpl implements IProjectService 
{
    @Autowired
    private ProjectMapper projectMapper;

    /**
     * 查询承包商项目
     * 
     * @param id 承包商项目主键
     * @return 承包商项目
     */
    @Override
    public Project selectProjectById(Long id)
    {
        return projectMapper.selectProjectById(id);
    }

    /**
     * 查询承包商项目列表
     *
     * @param project 承包商项目
     * @return 承包商项目
     */
    @Override
    public List<Project> selectList(Project project)
    {
        return projectMapper.selectProjectList(project);
    }

    /**
     * 查询承包商项目列表
     * 
     * @param project 承包商项目
     * @return 承包商项目
     */
    @Override
    public List<ProjectInfoRespVO> selectProjectList(Project project)
    {
        List<ProjectInfoRespVO> list = new ArrayList<>();
        List<Project> projects = selectList(project);
        for (Project pro: projects) {
            ProjectInfoRespVO projectInfoRespVO = new ProjectInfoRespVO();
            BeanUtils.copyProperties(pro,projectInfoRespVO);
            list.add(projectInfoRespVO);
        }
        return list;
    }

    /**
     * 新增承包商项目
     * 
     * @param project 承包商项目
     * @return 结果
     */
    @Override
    public int insertProject(Project project)
    {
        project.setCreateTime(DateUtils.getNowDate());
        return projectMapper.insertProject(project);
    }

    /**
     * 修改承包商项目
     * 
     * @param project 承包商项目
     * @return 结果
     */
    @Override
    public int updateProject(Project project)
    {
        project.setUpdateTime(DateUtils.getNowDate());
        return projectMapper.updateProject(project);
    }

    /**
     * 批量删除承包商项目
     * 
     * @param ids 需要删除的承包商项目主键
     * @return 结果
     */
    @Override
    public int deleteProjectByIds(Long[] ids)
    {
        return projectMapper.deleteProjectByIds(ids);
    }

    /**
     * 删除承包商项目信息
     * 
     * @param id 承包商项目主键
     * @return 结果
     */
    @Override
    public int deleteProjectById(Long id)
    {
        return projectMapper.deleteProjectById(id);
    }

    @Override
    public List<Project> selectStopProjectList(String status) {
        return projectMapper.selectStopProjectList(status);
    }

    @Override
    public List<Project> selectReturnProjectList(String status) {
        return projectMapper.selectReturnProjectList(status);
    }
}
